<template>
  <div class="nav-header">
    <i
      @click="iClick"
      :class="isFold ? 'el-icon-s-unfold' : 'el-icon-s-fold'"
      class="fold-menu"
    />

    <div class="content">
      <div class="">
        <bread-Crumb :bread-crumbs="breadCrumbs" />
      </div>

      <user-Info />
    </div>
  </div>
</template>

<script lang="ts">
import userInfo from '@/components/NaVHeader/userInfo.vue';
import breadCrumb from '@/components/NaVHeader/breadCrumb.vue';

import { defineComponent, computed } from 'vue';
import { searchBreadCrumbs } from '@/utils';
import { useStore } from '@/store';
import { useRoute } from 'vue-router';

export default defineComponent({
  emits: ['foldChange'],

  props: {
    isFold: {
      type: Boolean,
      default: false,
    },
  },

  setup(props, { emit }) {
    const iClick = function () {
      emit('foldChange', props.isFold);
    };

    const store = useStore();
    const breadCrumbs = computed(() => {
      const route = useRoute();
      const userMenus = store.state.login.userMenus;
      return searchBreadCrumbs(userMenus, route.path);
    });

    return {
      iClick,
      breadCrumbs,
    };
  },

  components: {
    userInfo,
    breadCrumb,
  },
});
</script>

<style lang="less" scoped>
.nav-header {
  display: flex;
  align-items: center;
  width: 100%;
  height: 100%;
  .fold-menu {
    font-size: 30px;
    cursor: pointer;
  }

  .content {
    height: 100%;
    width: 100%;
    display: flex;
    align-items: center;
    margin-left: 10px;
    justify-content: space-between;
  }
}
</style>
